import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

class VipController extends GetxController {
  // 使用 GetStorage 进行持久化存储
  final box = GetStorage();

  // 初始化数据
  RxString vipName = ''.obs;
  RxInt vipTime = 0.obs;

  @override
  void onInit() {
    super.onInit();
    // 从本地存储读取数据
    vipName.value = box.read('vipName') ?? '默认会员';
    vipTime.value = box.read('vipTime') ?? 0;
  }

  // 修改会员信息
  void updateVipName(String name) {
    vipName.value = name;
    box.write('vipName', name); // 持久化存储
  }

  void rechargeVipTime(int days) {
    vipTime.value += days;
    box.write('vipTime', vipTime.value); // 持久化存储
  }
}
